package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressbookMapper {
  //  @Select("select * from sky_take_out.address_book where is_default=#{isDefault}")
  //查询默认地址
     List<AddressBook> list(AddressBook addressBook);


    //新增地址
    @Insert("insert into sky_take_out.address_book (user_id, consignee, phone, sex, province_code, province_name, city_code, city_name, district_code, district_name, detail, label, is_default)" +
            "values (#{userId}, #{consignee}, #{phone}, #{sex}, #{provinceCode}, #{provinceName}, #{cityCode}, #{cityName},#{districtCode}, #{districtName}, #{detail}, #{label}, #{isDefault})")
    void add(AddressBook addressbook);
     //查询地址

    List<AddressBook> select();

  void update(AddressBook addressBook);
@Select("select * from sky_take_out.address_book where id=#{id}")
  AddressBook selectById(Long id);
@Delete("delete from sky_take_out.address_book where id=#{id}")
  void deleteID(Long id);
  /**
   * 根据 用户id修改 是否默认地址
   * @param addressBook
   */
  @Update("update sky_take_out.address_book set is_default = #{isDefault} where user_id = #{userId}")
  void updateIsDefaultByUserId(AddressBook addressBook);

}
